var express = require('express');
var router = express.Router();
var guangzhou = require('./scripts/guangzhou.js');
var shenzhen = require('./scripts/shenzhen.js');
var shanghai = require('./scripts/shanghai.js');
var beijing = require('./scripts/beijing.js');
var citys = {
  'guangzhou':guangzhou,
  'shanghai':shanghai,
  'shenzhen':shenzhen,
  'beijing':beijing,
}

/* GET users listing. */
router.get('/transfer', function(req, res, next) {
  var start = req.query.start;
  var end = req.query.end;
  var city = req.query.city;
  var result = citys[city].transfer(start,end);
  res.send(result);
});

router.get('/line', function(req, res, next) {
  var line = req.query.line;
  var city = req.query.city;
  var result  = citys[city].line(line); 
  res.send(result);
});
router.get('/stop', function(req, res, next) {
  var stop = req.query.stop;
  var city = req.query.city;
  var result =  citys[city].stop(stop);
  res.send(result);
});

router.get('/linelike', function(req, res, next) {
  var linelike = req.query.linelike;
  var city = req.query.city;
  var result =citys[city].lineLike(linelike);
  
  res.send(result);
});
router.get('/stoplike', function(req, res, next) {
  var stoplike = req.query.stoplike;
  var city = req.query.city;
  var result =citys[city].stopLike(stoplike);
  res.send(result);
});


module.exports = router;
